<template>
  <div>
    <el-dialog title="团队迁移" :visible.sync="dialogShow">
      <el-form :model="form">
        <el-form-item label="授权代码" :label-width="formLabelWidth">
          <el-input v-model="form.code_num" autocomplete="off" :disabled="true" />
        </el-form-item>
        <el-form-item label="授权名称" :label-width="formLabelWidth">
          <el-input v-model="form.anent_name" autocomplete="off" :disabled="true" />
        </el-form-item>
        <el-form-item label="新授权代码" :label-width="formLabelWidth">
          <el-input v-model="form.new_code_num" autocomplete="off" placeholder="请输入新的代理授权码" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogShow = false">取 消</el-button>
        <el-button type="primary" @click="onSubmit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { teamRemoveApi } from '@/api/agent'
export default {
  data() {
    return {
      form: {
        code_num: '',
        anent_name: '',
        new_code_num: '',
        brand_id: ''
      },
      formLabelWidth: '100px',
      dialogShow: false
    }
  },
  methods: {
    onSubmit() {
      console.log('submit')
      if (this.form.new_code_num === '') {
        this.$message.warning('请输入新的代理授权码!')
        return false
      }
      const data = {
        brand_id: this.form.brand_id,
        old_code_num: this.form.code_num,
        new_code_num: this.form.new_code_num
      }
      console.log(data)
      teamRemoveApi(data).then(res => {
        if (res.code === 200) {
          console.log('success')
          this.$message.success('团队迁移成功!')
          this.dialogShow = false
        }
      })
    }
  }
}
</script>

<style lang="sass" scoped>

</style>
